package com.zjuh.qss.common;


public class HtmlContentParser {
	/*
	public static List<String> parseForLinks(String content) {
		try {
			Parser parser = new Parser(content);
			LinkFetchNodeVisitor visitor = new LinkFetchNodeVisitor(true);
			parser.visitAllNodesWith(visitor);
			return visitor.getLinks();
		} catch (Exception e) {
			throw new RuntimeException(e);
		}
	}
	
	static class LinkFetchNodeVisitor extends NodeVisitor {

		private List<String> links = new ArrayList<String>();

		private boolean onlyAbsolute = true;
		
		private LinkFetchNodeVisitor(boolean onlyAbsolute) {
			super();
			this.onlyAbsolute = onlyAbsolute;
		}

		@Override
		public void visitTag(Tag tag) {
			String name = tag.getTagName();
			name = name.toLowerCase();
			if (!name.equals("a")) {
				return;
			}
			String href = tag.getAttribute("href");
			href = StringUtil.trimToEmpty(href);
			if (StringUtil.isEmpty(href)) {
				return;
			}
			if (href.equals("#")) {
				return;
			}
			if (onlyAbsolute) {
				if (href.startsWith("http://") || href.startsWith("https://")) {
					links.add(href);
				}
			} else {
				links.add(href);
			}
			
		}

		public List<String> getLinks() {
			return links;
		}
		
	}*/
	
}
